import { createRouter,createWebHashHistory,createWebHistory } from "vue-router";

//2.定义路由规则
const routes = [
    {
        path:"/index",
        component:()=> import("@/pages/index.vue"),
        children:[
            {
                path:"home",
                component:()=> import("@/views/home.vue"),
            },
            {
                path:"shop",
                component:()=> import("@/views/shop.vue"),
            },
            {
                path:"sort",
                component:()=> import("@/views/sort.vue"),
            },
            {
                path:"/:catchAll(.)", //重定向有变化
                redirect:"home"
            }
        ]
    },
    {
        path:"/list",
        component:()=> import("@/pages/list.vue")
    },
    {
        path:"/:catchAll(.*)",  //一级路由的重定向有变化
        redirect:"/index"
    }
];

//1.创建路由对象
let router = createRouter({
    //路由模式
    // history:createWebHashHistory(), //哈希
    history:createWebHistory(), //history

    //路由规则
    routes,

})

//2.导出
export default router


//3.挂载到app